const app =getApp()
Page({
  data: {
    list:[],
    loading:true
  },
  onLoad(options) {
    let that = this
    that.xInit()
  },
  onShow() {
   
  },
  xInit:function(){
    let that =this
    // 获取动作分类
    wx.cloud.callFunction({
      name: 'digital_therapy',
      data: {
        action: "get_classification_by_action"
      }
    }).then(res => {
      that.setData({
        list:res.result,
        loading:false
      })
    })
  },
  xToDetail:function(e){
    let pamars = e.currentTarget.dataset
    console.log(1)
    wx.navigateTo({
      url: '/subtool/pages/training/actionlist/index?id='+ pamars.id+'&name='+ pamars.name,
    })
  },
  xToAction:function(){
    console.log(app.globalData.product_buy)
    if(!app.globalData.product_buy){
      wx.showModal({
        title: "提示",
        content: "解锁Pro版",
        confirmText:'去解锁',
        success (res) {
          if (res.confirm) {
            that.xToProductde()
          }
        }
      })
      return
    }else{
      wx.navigateTo({
        url: '/subtool/pages/action/index/index?week==0&treatment_item_id=0',
      })
    }
  },
  xToProductde:function(){
    let that =this
    if(!app.globalData.user.phone_number){
      let path = '/pages/navigation/using/index'
      wx.navigateTo({
        url: '/pages/navigation/login/index?path='+path,
      })
    }else{
      wx.navigateTo({
        url: '/subsale/pages/product/index/index?choose=true&id=26da8e4962b93a6000ec7c3d68d9d3eb'
      })
    }
  },
})